package com.xijia.example.manage.all.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import com.xijia.example.manage.all.model.vo.SiteVO;
import com.xijia.example.manage.all.model.dto.SiteDTO;
import com.xijia.example.manage.all.model.query.SiteQuery;
import com.xijia.example.manage.all.service.SiteService;
import io.github.wslxm.springbootplus2.core.base.controller.BaseController;
import io.github.wslxm.springbootplus2.core.base.model.BasePage;
import io.github.wslxm.springbootplus2.core.constant.BaseConstant;
import io.github.wslxm.springbootplus2.core.result.Result;

/**
 * 站点管理 前端控制器
 *
 * <p>
 * ::本代码由[兮家小二]提供的代码生成器生成,如有问题,请手动修改 ::作者CSDN:https://blog.csdn.net/qq_41463655
 * </p>
 *
 * @author ws
 * @email 1720696548@qq.com
 * @date 2024-09-25 11:36:42
 */
@RestController
@RequestMapping(BaseConstant.Uri.API_ADMIN + "/all/site")
@Api(value = "SiteController", tags = "站点管理")
public class SiteController extends BaseController<SiteService> {

    @GetMapping(value = "/findPage")
    @ApiOperation(value = "列表查询")
    public Result<BasePage<SiteVO>> findPage(@ModelAttribute @Validated SiteQuery query) {
        return Result.success(baseService.findPage(query));
    }

    @GetMapping(value = "/{id}")
    @ApiOperation(value = "ID查询")
    public Result<SiteVO> findId(@PathVariable String id) {
        return Result.success(baseService.findId(id));
    }

    @PostMapping
    @ApiOperation(value = "添加")
    public Result<String> insert(@RequestBody @Validated SiteDTO dto) {
        return Result.successInsert(baseService.insert(dto));
    }

    @PutMapping(value = "/{id}")
    @ApiOperation(value = "ID编辑")
    public Result<Boolean> upd(@PathVariable String id, @RequestBody @Validated SiteDTO dto) {
        return Result.successUpdate(baseService.upd(id, dto));
    }

    @DeleteMapping(value = "/{id}")
    @ApiOperation(value = "ID删除")
    public Result<Boolean> del(@PathVariable String id) {
        return Result.successDelete(baseService.del(id));
    }


    @PostMapping(value = "/siteChecks/{id}")
    @ApiOperation(value = "站点检查")
    public Result<Boolean> siteChecks(@PathVariable String id) {
        return Result.success(baseService.siteChecks(id), "检查完成");
    }

}
